﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace psafth.AMB.Objects
{
    public class PassingObject
    {
        public ulong DecoderId
        {
            get;
            private set;
        }

        public ulong TransponderId
        {
            get;
            private set;
        }

        public DateTime PassingTime
        {
            get;
            private set;
        }

        public double SignalStrength
        {
            get;
            private set;
        }

        public ulong Hits
        {
            get;
            private set;
        }

        public double Voltage
        {
            get;
            private set;
        }

        public double Temperature
        {
            get;
            private set;
        }

        public PassingObject(List<DataObject> rl)
        {
            foreach (DataObject r in rl)
            {
                switch (r.DataType)
                {
                    case (int)AMBGeneralFOR.DECODER_ID:
                        this.DecoderId = AMBCalculator.GetDecoderId(r.Data);
                        break;

                    case (int)AMBPassingFOR.TRANSPONDER:
                        this.TransponderId = AMBCalculator.GetTransponderId(r.Data);
                        break;

                    case (int)AMBPassingFOR.RTC_TIME:
                        this.PassingTime = AMBCalculator.GetPassingTime(r.Data);
                        break;

                    case (int)AMBPassingFOR.STRENGTH:
                        this.SignalStrength = AMBCalculator.GetSignalStrength(r.Data);
                        break;

                    case (int)AMBPassingFOR.VOLTAGE:
                        this.Voltage = AMBCalculator.GetUlong(r.Data) / 10;
                        break;

                    case (int)AMBPassingFOR.HITS:
                        this.Hits = AMBCalculator.GetUlong(r.Data);
                        break;

                    case (int)AMBPassingFOR.TEMPERATURE:
                        this.Temperature = AMBCalculator.GetUlong(r.Data) - 100;
                        break;
                }
            }
        }
    }
}
